<template>
  <a-modal :title='"商品批号选择---"+this.drugsName'  :dialog-style="{ top: '10px' }" :zIndex='2000' width='950px' :visible='visible' :confirmLoading='loading' :footer='null' @cancel='handleCancel'>
    <f-table ref='table' rowKey='drugsLotId' :rowSelection='rowSelection' :scroll='{x:800,y:410}' @dblclick='dblclick' v-if='visible' :columns='columns' :multiple='false' :showRadio='true' :params='queryParam' :api='api.bpd.selectLotNoByDrugsId' :showPagination='false' @onSelectChange='onSelectChange'>
    </f-table>
  </a-modal>
</template>
<script>
import api from "../js/api"

export default {
  name: "SelectHyDrugsLotModal",
  props: {},
  data() {
    return {
      refs: this.$refs,
      api: Object.assign(api, this.api),
      loading: false,
      visible: false,
      selectedRowKeys: [],
      selectedRows: [],
      drugsName: "",
      //列表初始化查询参数
      queryParam: {
        policyDrugId: ""
      },
      // 表头
      columns: [
        {
          title: "库存数量",
          align: "center",
          width: "80px",
          dataIndex: "surplusNum"
        },
        {
          title: "在单数",
          align: "center",
          width: "80px",
          dataIndex: "onUseCount"
        },
        {
          title: "仓库名称",
          align: "center",
          width: "130px",
          dataIndex: "storeName"
        },
        {
          title: "批号",
          align: "center",
          width: "80px",
          dataIndex: "drugLotNo"
        },
        {
          title: "可开票数",
          align: "center",
          width: "80px",
          dataIndex: "canUseNum"
        },
        {
          title: "件容",
          align: "center",
          width: "80px",
          dataIndex: "drugJr"
        },
        {
          title: "整件数",
          align: "center",
          width: "80px",
          dataIndex: "wholeNum"
        },
        {
          title: "零货数",
          align: "center",
          width: "80px",
          dataIndex: "partNum"
        },
        {
          title: "有效期",
          align: "center",
          width: "80px",
          dataIndex: "expirationDate"
        },
        {
          title: "生产日期",
          align: "center",
          width: "80px",
          dataIndex: "generationDate"
        }
      ]
    }
  },
  computed: {
    rowSelection() {
      return {
        type: "radio",
        getCheckboxProps: record => ({
          props: {
            disabled: record.canUseNum <= 0
          }
        })
      }
    }
  },
  methods: {
    open(drugNo, drugsName) {
      this.queryParam.drugNo = drugNo
      this.drugsName = drugsName
      this.visible = true
      this.selectedRowKeys = []
      this.selectedRows = []
    },

    dblclick(record, event) {
      let canUseNum = record.canUseNum
      if (canUseNum <= 0) {
        this.$message.success("库存不足")
        return
      }
      this.$emit("drugsLotSelectChange",record)
      this.close()
    },
    close() {
      this.$emit("close")
      this.visible = false
    },
    handleCancel() {
      this.close()
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    }
  },
  created() {
  },
  components: {}
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
